Promotional Transformation on Monadic Programs

نویسندگان

  • Zhenjiang Hu
  • Hideya Iwasaki
  • Masato Takeichi
چکیده

Monads, proposed by Moggi [16] of their use in structuring denotational descriptions and then popularized by Wadler[21], are becoming an increasingly important tool for structural functional programming[8, 10, 11]. The reason is that monads provide a uniform framework for describing a wide range of programming language features including, for example, state, I/O, continuations, exceptions, parsing and non-determinism, without leaving the framework of a purely functional language. Programs using monads, which will be called monadic programs hereafter, can be structured once again over data type for facilitating program transformation [5, 9, 15]. It is known that each data type comes equipped with a catamorphism[13, 14] (i.e., a generalized fold[18]) which satis es several laws that are very useful for program transformation. Fokkinga[5] derived a su cient condition under which there is also a kind of so-called monadic catamorphism which satisfy similar laws and can thus be used for transformation of monadic programs. Apart from the theoretical study, very recently, Meijer and Jeuring[15] discussed the simultaneous use of catamorphisms and monads in practical functional programming. They convincingly demonstrated through many examples that by programming in this style resulting programs are of an astonishing clarity and conciseness. Categorically speaking, monadic catamorphisms are the lifting of normal catamorphisms to the Kleisli category[5]. This is also the approach taken in the Algebraic Design Language (ADL) [9]. Despite its mathematical elegance, Fokkinga's theory contains an assumption on monad that is not valid for several known monads, in particular it is not valid for the state monad. Therefore, for these monads, the whole reasoning of Fokkinga's doesn't make sense (see the conclusion in [5]). Meijer and Jeuring[15] solved this problem informally in their case study of deriving an e cient abstract G-machine from an initial naive monadic program related to the state monad; they de ned their speci c monadic catamorphism in terms of a normal catamorphism and found some transformation rules for the calculation of monadic programs based on the fusion laws (i.e., promotion theorem) for the normal catamorphism. However, a general study on direct transformation of monadic catamorphisms was not given.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Promotional Transformation of Monadic Programs

Monads are becoming an increasingly important tool for structural functional programming, because they provide a uniform framework for describing a wide range of programming language features. To facilitate program transformation, Fokkinga derived a su cient assumption under which there is a kind of socalled monadic catamorphisms which satisfy several general laws useful for the transformation ...

متن کامل

On Optimization of Monadic Logic Programs

The article is devoted to the optimization of monadic logic programs and goals (programs and goals, which do not use functional symbols of arity > 1 and use only predicate symbols of arity 1). A program P is terminating with respect to a goal G, if an SLD-tree of P and G is finite. In general, monadic programs are not terminating. Program and goal transformations are introduced, by which a mona...

متن کامل

Monadification of functional programs

The structure of monadic functional programs allows the integration of many different features by just changing the definition of the monad and not the rest of the program, which is a desirable feature from a software engineering and software maintenance point of view. We describe an algorithm for the automatic transformation of a group of functions into such a monadic form. We identify two cor...

متن کامل

Transforming Functional Logic Programs into Monadic Functional Programs

We present a high-level transformation scheme to translate lazy functional logic programs into pure Haskell programs. This transformation is based on a recent proposal to efficiently implement lazy non-deterministic computations in Haskell in a monadic style. We build on this work and define a systematic method to transform lazy functional logic programs into monadic programs with explicit shar...

متن کامل

Combining Logic Programs and Monadic Second Order Logics by Program Transformation

We present a program synthesis method based on unfold/fold transformation rules which can be used for deriving terminating definite logic programs from formulas of the Weak Monadic Second Order theory of one successor (WS1S). This synthesis method can also be used as a proof method which is a decision procedure for closed formulas of WS1S. We apply our synthesis method for translating CLP(WS1S)...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1995